<?php

namespace app\data\controller\api;

use app\data\model\NotarialOffice as NotarialOfficeModel;
use app\data\service\NotarialOffice as NotarialOfficeSerice;
use think\admin\Controller;

/**
 * 公证处接口
 * Class Data
 * @package app\data\controller\api
 */
class NotarialOffice extends Controller
{

    /**
     * 获取公证处
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getNotarialOffice()
    {
        $where[] = ['status','=',1];
        $where[] = ['deleted','=',0];
        $data = NotarialOfficeModel::field('id,name')->where($where)->order('id desc')->select()->toArray();
        $this->success('获取成功', $data);
    }

    /**
     * 获取公证事项
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getNotarizedMatters()
    {
        $notarial_office_id = input('post.notarial_office_id',0);//公证处id
        if (empty($notarial_office_id)) {
            $this->error('请选择公证处！');
        }
        $data = NotarialOfficeSerice::getNotarizedMatters($notarial_office_id);
        $this->success('获取成功', $data);
    }
}